<?php


  function UploadOne($a){


 
  $config = array(

        'rootPath' => 'Public/',        
        'maxSize'    =>    3145728,  
        'savePath'   =>    './Public/Uploads/', 
        'saveName'   =>    array('uniqid',''),   
        'exts'       =>    array('jpg', 'gif', 'png', 'jpeg'), 
       'autoSub'    =>    true,   
       'subName'    =>    array('date','Ymd'),

      );

    $upload = new \Think\Upload($config);

    // 2.执行文件上传操作(单文件上传)
    $info = $upload->uploadOne($_FILES['photo']);

    // dump($info);
   
    // 判断文件上传是否成功
    if($info){
         
         $data['photo'] = $info['savepath'].$info['savename'];

    }else{

         echo $upload->getError();
    }


    }

